//
//  GroupSelector.swift
//  eemall
//
//  Created by zhuxietong on 2018/12/25.
//  Copyright © 2018 tianrun. All rights reserved.
//

import UIKit
import soapp
import AsyncDisplayKit
import JoLoading
import Eelay

open class GroupSelector: EeAlertView,ASTableVConfig,LoadingPresenter{
    public var loadingPresenterInset: UIEdgeInsets{
        get{
            .zero
        }
    }
    public func touch(cell: Any, actionID: String, model: NSMutableDictionary) {
        
    }
    
    public var LoadingPresenterBg: UIView{
        return contentView
    }
    
    open override func addLayoutRules() {
        jo_contentView.eelay = [
            [tableView,[ee.T.L.B.R]]
        ]
        tableView.separatorStyle = .none
        tableView.hidenMoreLine()
        configTables(nodes: tableNode)
        mo_model_reload()
    }
    
    
    public var tableNode:ASTableNode = ASTableNode(style: .plain)
    var tableView:UITableView{
        get{
            return tableNode.view
        }
    }
    
    let selector = [
        "<default>":ItemCell.self
    ]
    
    var sections:TP.section = [
        [
            ["cell":"one"],
            ["cell":"one"],
            ["cell":"one"],
            ["cell":"one"],

        ]
    ]
    
    open override func mo_model_reload() {
        tableNode.load(sections: sections, selector: selector)
        tableNode.reloadData()
    }
    
    open override var intrinsicContentSize: CGSize{
        return [(Swidth-AppTheme.edge * 2.0),300]
    }


}

extension GroupSelector{
    
    class GroupOwerCell: JoCellNode {
        let headV = JoImageNode()
        let nameL = ASTextNode2()
        let createTimeL = ASTextNode2()
        let timerL = ASTextNode2()
        let infoL = ASTextNode2()
        
        override func addLayoutRules() {
            headV.img_url = __heads.one_str
            nameL.attributedText = __names.one_str.ui.font13.cl_333.astring
            nameL.attributedText = __names.one_str.ui.font13.cl_333.astring

        }
        
        override func specGetter() -> _Spec {
            let sepc = _Spec.stack(["v|10",&-.center], childs: [
                headV["68",68],
                nameL.Spec,
                createTimeL.Spec,
                timerL.Spec,
                infoL.Spec
                ])
            return sepc
        }
        
    }
    
    class ItemCell: GroupGoodsDetailCtr.GroupCell {
        
    }
}
